class ShopView {
    static show(character, items = ShopItems) {
        ModalManager.show('#shop-modal', {
            onShow: (content) => {
                content.querySelector('.shop-items').innerHTML = items.map(item => `
                    <div class="shop-item">
                        <div class="item-info">
                            <h3>${item.name}</h3>
                            <p>${item.description}</p>
                            <span class="item-price">💰 ${item.price}</span>
                        </div>
                        <button class="buy-btn" data-item-id="${item.id}">购买</button>
                    </div>
                `).join('');

                // 添加购买事件
                content.querySelectorAll('.buy-btn').forEach(btn => {
                    btn.onclick = () => ShopView.buyItem(character, btn.dataset.itemId);
                });
            }
        });
    }

    static buyItem(character, itemId) {
        const item = ShopItems.find(i => i.id === itemId);
        if (!item) return;
        
        if (character.gold >= item.price) {
            character.gold -= item.price;
            character.inventory.push(item);
            NotificationManager.success(`购买了 ${item.name}`);
        } else {
            NotificationManager.error('金币不足！');
        }
    }
} 